<?php

namespace App\Jobs;

use Carbon\Carbon;
use App\Models\GoldRecord;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use App\Services\RewardGoldPrize\RewardTeamParents;

class RewardTeamParentsJob implements ShouldQueue
{
	use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

	public GoldRecord $record;

	public function __construct(GoldRecord $record)
	{
		$this->record = $record;
	}

	public function handle()
	{
        $record = $this->record;
		app(RewardTeamParents::class)->reward($this->record);
		$record->update(['rewarded_at' => Carbon::now()]);
	}
}
